import api from '../../mock/index.js'
import { getSCGoods, submitSurvey } from '../../api/index.js'
	
const store = {
	state: {
		list: [],
		result: null
	},
	
	mutations: {
		updateList(state, list) {
			state.list = list
		},
		
		updateResult(state, result) {
			state.result = result
		}
	},
	
	actions: {	
		// 通过筛查结果获取商品
		async getSCGoods({ commit, state }, param = {}) {
			let res = await api.post(getSCGoods, param)
			commit('updateList', res.data)
		},
		
		// 提交筛查项
		async submitSurvey({ commit }, params = {}) {
			let res = await api.post(submitSurvey, params)
			commit('updateResult', res.data)
			return res
		}
	},
	namespaced: true
}

export default store
